#!/bin/bash
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
set -e
 
PATH="$PATH:/usr/X11R6/bin/"
 
# The Username:Group that will run VNC
export USER="peter"
#${RUNAS}
 
# The display that VNC will use
DISPLAY="2"
 
# Color depth (between 8 and 32)
DEPTH="24"
 
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
#GEOMETRY="1024x768"
GEOMETRY="1920x1080"
#GEOMETRY="1280x1024"
 
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
 
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
 
#. /lib/lsb/init-functions
 
case "$1" in
start)
 /usr/bin/vncserver ${OPTIONS}
 echo connect on port 5902
 ;;
 
stop)
 /usr/bin/vncserver -kill :${DISPLAY}
 ;;
 
restart)
 $0 stop
 $0 start
 ;;

*)
 echo "Use Option stop start or restart"
 ;;

esac
 
exit 0
